/*
 * @Author       : xh
 * @Date         : 2022-10-21 14:47:13
 * @LastEditors  : xh
 * @FileName     :   
 */
import localStorage from 'js-cookie'
// const localStorage = window.localStorage
const TokenKey = 'YL_DATACENTER_TOKEN'
const RefreshTokenKey = 'YL_DATACENTER_REFRESHTOKEN'
const UserIdKey = 'YL_DATACENTER_USERID'
const TokenExpTimeKey = 'YL_DATACENTER_TOKENEXPTIME'
const config = {
  development: {
    expires: 7
  },
  test: {
    domain: '.964yx.com',
    expires: 7
  },
  production: {
    domain: '.964yx.com',
    expires: 7
  },
  release: {
    domain: '.964yx.com',
    expires: 7
  }
}

export function getToken() {
  return [localStorage.get(TokenKey), localStorage.get(RefreshTokenKey), localStorage.get(UserIdKey), localStorage.get(TokenExpTimeKey)]
}

export function setToken(Token, RefreshToken, UserId, TokenExpTime) {
  localStorage.set(TokenKey, Token, config[process.env.NODE_ENV])
  localStorage.set(RefreshTokenKey, RefreshToken, config[process.env.NODE_ENV])
  localStorage.set(UserIdKey, UserId, config[process.env.NODE_ENV])
  localStorage.set(TokenExpTimeKey, TokenExpTime, config[process.env.NODE_ENV])
}

export function removeToken() {
  localStorage.remove(TokenKey, config[process.env.NODE_ENV])
  localStorage.remove(RefreshTokenKey, config[process.env.NODE_ENV])
  localStorage.remove(UserIdKey, config[process.env.NODE_ENV])
  localStorage.remove(TokenExpTimeKey, config[process.env.NODE_ENV])
}